<%@ page language="java" pageEncoding="UTF-8" %>
<%@page import="com.gjintel.sdk.util.ProcessDefinitionCache" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ include file="/commons/jsp/taglibs.jsp" %>
<%@taglib uri="http://www.framework.com/taglib" prefix="frame" %>
<head>
    <title>公共平台 </title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <!-- 样式文件的引入 -->
    <link href="${ctx}/commons/css/style.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/commons/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/commons/themes/icon.css">
    <!-- jqueryUI JS文件的引入 -->
    <script type="text/javascript" src="${ctx}/commons/js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="${ctx}/commons/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${ctx}/commons/js/easyui-extends-validate.js"></script>
    <!-- jqueryUI国际化 -->
    <script type="text/javascript" src="${ctx}/commons/js/easyui-lang-zh_CN.js"></script>
    <!-- 开发使用的公用js方法 -->
    <script type="text/javascript" src="${ctx}/commons/js/common.js"></script>
    <!-- 开发国际化的引用，主要完成后台信息在前台提示的国际化，一定要放在最后 -->
    <script type="text/javascript">var ctx = '${ctx}';
    var actionExt = "action";
    var i18n = new Object();</script>
    <script src="${ctx}/commons/js/i18n/message_zh_CN.js" type="text/javascript"></script>
</head>

<body>
<div class="easyui-layout" data-options="fit:true,border:false">


    <div data-options="region:'north',border:false" style="padding: 4px;height: 50px;overflow: hidden;">
        <div class="easyui-panel" data-options="fit:true,border:true">
            <div class="queryContent">
                <form name="searchForm" id="searchContentForm" method="post" action="" style="display: none; ">
                    <table class="queryTable">
                        <tbody>
                        <tr>
                            <th width="80%">BusinessKey</th>
                            <td width="10%">
                                <input class="easyui-validatebox" type="text" name="businessKey" maxlength="32"
                                       style="width:120px"></input></td>
                            <td align="right" width="10%"><a href="javascript:void(0);" class="easyui-linkbutton"
                                                             id="searchContent" plain="true">查询</a>
                                <a href="javascript:void(0);" class="easyui-linkbutton" id="resetSearchContent"
                                   plain="true">清空</a></td>
                        </tr>
                        </tbody>
                    </table>
                </form>
            </div>
        </div>
    </div>


    <div data-options="region:'center',border:false" style="padding: 4px;">
        <input type="hidden" id="revoke" value="${revoke}"/>
        <table id="listOrderTable" class="easyui-datagrid"
               data-options="singleSelect:true,toolbar:'#tb',method:'post',rownumbers:true,fit:true,fitColumns:true,border:true,
					pagination:true,remoteSort:true,multiSort:true,striped:true,onLoadSuccess:function(data){$('#'+paramObj.searchID).attr('disabled',false);},
					url:'${ctx }/workflow/running'" }>
            <thead>
            <tr>
                <th data-options="field:'id',width:20,title:'执行ID',sortable:true" align="center"></th>
                <th data-options="field:'processInstanceId',width:20,title:'流程实例ID',sortable:true" align="center"></th>
                <th data-options="field:'processDefinitionId',width:20,title:'流程定义ID',sortable:true"
                    align="center"></th>
                <th data-options="field:'businessKey',width:30,title:'BusinessKey',sortable:true" align="center"></th>
                <th data-options="field:'nodeName',width:20,formatter: getCurrentNode,title:'当前节点',sortable:true"
                    align="center"></th>
                <th data-options="field:'suspended',width:20,title:'是否挂起',sortable:true" align="center"></th>
                <th data-options="field:'options',width:20,title:'操作',formatter:getOptionsBtn" align="center"></th>
            </tr>
            </thead>
        </table>
        </table>
    </div>
</div>
</body>
<script type="text/javascript">
    //初始化表格对应的js对象
    var paramObj;
    $(function () {
        //初始化表格对象数据
        paramObj = new initParams(
            {
                paramObjName: 'paramObj',//表格对应的实体对象名称，好区分多个表格情况下的对象
                tableId: 'listOrderTable',
                addDataFormId: 'addContentDataForm',
                showDialogId: 'shoContentDialog',
                searchID: 'searchContent',
                resetSearchID: 'resetSearchContent',
                searchFormID: 'searchContentForm',
                //updateUrl: '${ctx}/workflow/input?id=',
                //deleteUrl: '${ctx}/workflow/remove',
                addDialogWidth: 980,
                addDialogHeight: 600,
                ctx: '${ctx}',
                addDialogTitle: '文章信息'
            });
        //初始化查询
        init(paramObj);
    });

    //操作
    function getOptionsBtn(value, row, index) {
        var html = "test";
        if (row.suspended) {
            html = "<a href='processdefinition/update/active/" + row.processInstanceId + "'>激活</a>";
        } else {
            html = "<a href='processdefinition/update/suspend/" + row.processInstanceId + "'>挂起</a>";
        }
        return html;
    }

    //查看当前节点名称
    function getCurrentNode(value, row, index) {
        //var nodeName=
        return "<a href='#' onclick='openProcessTracePicture(" + row.id + ")'>" + value + "</a>";
    }

    /**
     * 查看流程追踪
     */
    function openProcessTracePicture(id) {
        top.$('#firstLevelDialog').dialog({
            title: "流程追踪",
            iconCls: 'icon-view',
            width: 900,
            height: 520,
            closed: false,
            inline: true,
            cache: false,
            href: "${ctx }/workflow/process/trace?processInstanceId=" + id,
            modal: true,
            buttons: [{
                text: "取消",
                iconCls: 'icon-cancel',
                handler: function () {
                    top.$('#firstLevelDialog').dialog('close');
                }
            }]
        });
    }

</script>